_require local "../../../../basis.smi"
_require local "../../../data/symbols/main/Loc.smi"
_require local "../../../data/symbols/main/Symbol.smi"
_require local "../../../data/symbols/main/RecordLabel.smi"
_require local "../../../extensions/debug/main/Bug.smi"

_require "../../../libs/ids/main/LocalID.smi"
_require "../../../libs/env/main/IEnv.smi"
_require "./Types.ppg.smi"
_require "./VarInfoEnv.smi"
_require "./TvarMap.smi"

structure TypesBasics =
struct
  exception CoerceFun 
  exception CoerceTvarKindToEQ 
  val derefTy : Types.ty -> Types.ty
  val substBTvar : Types.ty BoundTypeVarID.Map.map -> Types.ty -> Types.ty
  val freshSubst : Types.btvEnv -> Types.ty BoundTypeVarID.Map.map
  val freshSubstWithLambdaDepth
      : Types.lambdaDepth -> Types.btvEnv -> Types.ty BoundTypeVarID.Map.map
  val freshRigidSubst : Types.btvEnv -> Types.ty BoundTypeVarID.Map.map
  val freshRigidSubstWithLambdaDepth
      : Types.lambdaDepth ->  Types.btvEnv -> Types.ty BoundTypeVarID.Map.map
  val monoTy : Types.ty -> bool
  val freshRigidInstTy : Types.ty -> Types.ty * Types.constraint list * Types.tvState ref TvarMap.map
  val freshTopLevelRigidInstTy : Types.ty -> Types.ty * Types.constraint list * Types.ty list
  val EFTV : Types.ty * Types.constraint list
             -> int * OTSet.set * (Types.tvState ref) IEnv.map
(*
  val OEFTV : Types.ty * Types.constraint list
             -> int * OTSet.set * (Types.tvState ref) IEnv.map
*)
  val EFBTV : Types.ty -> BoundTypeVarID.Set.set
  val adjustDepthInTy : bool ref -> Types.lambdaDepth -> Types.ty -> unit
  val adjustDepthInTvarKind : bool ref -> Types.lambdaDepth -> Types.tvarKind -> unit
  val generalizer : Types.ty * Types.constraint list * Types.lambdaDepth
                    -> {boundEnv: Types.btvEnv, removedTyIds: OTSet.set, boundConstraints : Types.constraint list}
  val performSubst : Types.ty * Types.ty -> unit
  val copyBoundEnv
      : Types.btvEnv -> Types.ty BoundTypeVarID.Map.map * Types.btvEnv
  val coerceFunM
      : Types.ty * Types.ty list 
        -> Types.ty list * Types.ty * Types.ty list option *
           Types.constraint list
  val tpappTy : Types.ty * Types.ty list -> Types.ty
  val tyConFromConTy : Types.ty -> Types.tyCon
  val tpappPrimTy :
      {boundtvars: Types.btvEnv, argTyList: Types.ty list, resultTy: Types.ty}
      * Types.ty list
      -> {argTyList: Types.ty list, resultTy: Types.ty}
  val tupleTy : Types.ty list -> Types.ty
end
